<?php

namespace Modules\Admin\Http\Controllers\Ebooks;

use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Modules\Common\General\Security\Api\Gateway;
use Modules\Common\Models\AdminLog;
use Modules\Common\Models\Ebooks;
use Modules\Common\Util\Api;
use Modules\Common\Util\Database;


class Create
{
    /**
     *
     * @Route(path=/api/admin/ebook  method=post)
     */
    public function index()
    {
        $adminUserIdDefault = auth('api')->user()->id;
        $eidDefault = auth('api')->user()->eid; 
        $sidDefault = auth('api')->user()->sid; 
        $ebooks = new Ebooks();
        $ebooks->book_name = request('book_name');
        $ebooks->author = request('author');
        $ebooks->category_id = request('category_id');
        $ebooks->publisher = request('publisher');
        $ebooks->publish_date = request('publish_date');
        $ebooks->underlined_price = request('underlined_price');
        $ebooks->price = request('price');
        $ebooks->format = request('format');
        $ebooks->is_recommend = request('is_recommend');
        $ebooks->description = request('description');
        $ebooks->is_free = request('is_free');
        $ebooks->available = request('available');
        $ebooks->cover_image = request('cover_image');
        $ebooks->is_published = request('is_published');
        $ebooks->ebook_fileid = request('ebook_fileid');
        $ebooks->admin_user_id = $adminUserIdDefault;
        $ebooks->eid = $eidDefault;
        $ebooks->sid = $sidDefault;
        $ebooks->created_at = date('Y-m-d H:i:s');
        $ebooks->save();
        return Api::success($ebooks);
    }

}